var oldVerificationCode="";
$(function(){
	eachPanelClick();
	$("#btnVerificationCodePD").on('click',function(obj){
		getVerificationCodePD();
	});
	$("#btnSurePD").on('click',function(obj){
		submitMesPD();
	});
	$("#btnSubmitPD").on('click',function(obj){
		submitPD();
	});
	
	/*$("#btnVerificationCodeMB").on('click',function(obj){
		getVerificationCodeMB();
	});
	$("#btnSureMB").on('click',function(obj){
		submitMesMB();
	});
	$("#newBtnVerificationCodeMB").on('click',function(obj){
		newGetVerificationCodeMB();
	});
	$("#newBtnSureMB").on('click',function(obj){
		newSubmitMesMB();
	});*/
});
function eachPanelClick(){
	$(".edit-icon-btn").each(function(i,obj){
		$(obj).on('click',function(ot){
			var $pnl=$(".edit-panel-body");
			if($pnl.eq(i).is(".hidden")){
				$pnl.eq(i).show();
				$pnl.eq(i).removeClass("hidden");
			}else{
				$pnl.eq(i).hide();
				$pnl.eq(i).addClass("hidden");
			}
		});
	});
};
/*获取验证码-修改密码*/
function getVerificationCodePD(){
	var memberMobilePD=$("#memberMobilePD").val().trim();
	if(memberMobilePD==null || memberMobilePD==""){
		consoleMes($("#manageContent"),2000,"warning","请输入手机！");
		return;
	}
	if(!ischeckmobile(memberMobilePD)){
		consoleMes($("#manageContent"),2000,"warning","手机格式不正确！");
		return;
	}
	$("#memberMobilePD").attr("disabled","disabled");
	consoleMes($("#manageContent"),2000,"success","验证码已经发送至手机！");//success、info、warning、danger
	/*$.ajax({
        type: "GET",
        url:  gobalWebUrl+"member/login",
        async: true,//false使用同步的方式,true为异步方式
        contentType: "application/json; charset=utf-8",
        data:{"phone":memberMobilePD},
        dataType: "json",
        success:function(backData){
            if(backData.result==202){
            	oldVerificationCode=backData.rows.code;
            	$("#manageContent").attr({"tgid":backData.rows.id});
            	$("#memberMobilePD").attr("disabled","disabled");
            	consoleMes($("#manageContent"),2000,"success","验证码已经发送至手机！");//success、info、warning、danger
            }else{
            	consoleMes($("#webContent"),2000,"warning",backData.message);//success、info、warning、danger
            	
            }
        },
        error:function(backData){

        }

    });*/
}
/*提交手机和验证码-修改密码*/
function submitMesPD(){
	var memberMobilePD=$("#memberMobilePD").val().trim();
	var verificationCodePD=$("#verificationCodePD").val().trim();
	if(memberMobilePD==null || memberMobilePD==""){
		consoleMes($("#manageContent"),2000,"warning","请输入手机！");
		return;
	}
	if(!ischeckmobile(memberMobilePD)){
		consoleMes($("#manageContent"),2000,"warning","手机格式不正确！");
		return;
	}
	if(verificationCodePD==null || verificationCodePD==""){
		consoleMes($("#manageContent"),2000,"warning","请输入验证码！");
		return;
	}
	if(verificationCodePD!="666"){
		consoleMes($("#manageContent"),2000,"warning","验证码不正确！");
		return;
	}
	consoleMes($("#manageContent"),2000,"success","正在跳转密码修改！");//success、info、warning、danger
	setTimeout(function () {
    	$(".verification-item").eq(0).hide();
    	$(".safe-item").eq(0).show();
    }, 2500);
}
/*提交修改密码*/
function submitPD(){
	var tgid=$("#manageContent").attr("tgid");
	var newMemberPassword=$("#newMemberPassword").val().trim();
	var repeatMemberPassword=$("#repeatMemberPassword").val().trim();
	if(newMemberPassword==null || newMemberPassword=="" || newMemberPassword.length<6){
		consoleMes($("#manageContent"),2000,"warning","密码不能为空，且长度须不小于6位！");
		return;
	}
	if(newMemberPassword!=repeatMemberPassword){
		consoleMes($("#manageContent"),2000,"warning","两次密码输入不一致！");
		return;
	}
	consoleMes($("#manageContent"),2000,"success","密码修改成功，正在跳转登录页面！");//success、info、warning、danger
	setTimeout(function () {
    	window.location.href=gobalWeb+"login.html";
    }, 2500);
    if(tgid!=null && tgid>0){
		/*$.ajax({
	        type: "GET",
	        url:  gobalWebUrl+"member/login",
	        async: true,//false使用同步的方式,true为异步方式
	        contentType: "application/json; charset=utf-8",
	        data:{"id":tgid,"password":newMemberPassword},
	        dataType: "json",
	        success:function(backData){
	            if(backData.result==202){
	            	consoleMes($("#manageContent"),2000,"success","密码修改成功，正在跳转登录页面！");//success、info、warning、danger
					setTimeout(function () {
				    	window.location.href=gobalWeb+"login.html";
				    }, 2500);
	            }else{
	            	consoleMes($("#manageContent"),2000,"warning",backData.message);//success、info、warning、danger
	            	
	            }
	        },
	        error:function(backData){
	
	        }
	
	    });*/
  	}else{
		consoleMes($("#manageContent"),2000,"warning","无法提交，请刷新页面重试！");
	}
}
/*获取验证码-更改手机*/
/*function getVerificationCodeMB(){
	var memberMobileMB=$("#memberMobileMB").val().trim();
	if(memberMobileMB==null || memberMobileMB==""){
		consoleMes($("#manageContent"),2000,"warning","请输入手机！");
		return;
	}
	if(!ischeckmobile(memberMobileMB)){
		consoleMes($("#manageContent"),2000,"warning","手机格式不正确！");
		return;
	}
	consoleMes($("#manageContent"),2000,"success","验证码已经发送至手机！");//success、info、warning、danger
	$.ajax({
        type: "GET",
        url:  gobalWebUrl+"member/login",
        async: true,//false使用同步的方式,true为异步方式
        contentType: "application/json; charset=utf-8",
        data:{"count":memberMobile},
        dataType: "json",
        success:function(backData){
            if(backData.result==202){
            	consoleMes($("#manageContent"),2000,"success",backData.message);//success、info、warning、danger
            }else{
            	consoleMes($("#manageContent"),2000,"warning",backData.message);//success、info、warning、danger
            	
            }
        },
        error:function(backData){

        }

    });
}*/
/*提交手机和验证码-更改手机*/
/*function submitMesMB(){
	var memberMobileMB=$("#memberMobileMB").val().trim();
	var verificationCodeMB=$("#verificationCodeMB").val().trim();
	if(memberMobileMB==null || memberMobileMB==""){
		consoleMes($("#manageContent"),2000,"warning","请输入手机！");
		return;
	}
	if(!ischeckmobile(memberMobileMB)){
		consoleMes($("#manageContent"),2000,"warning","手机格式不正确！");
		return;
	}
	if(verificationCodeMB==null || verificationCodeMB==""){
		consoleMes($("#manageContent"),2000,"warning","请输入验证码！");
		return;
	}
	if(verificationCodeMB!="666"){
		consoleMes($("#manageContent"),2000,"warning","验证码不正确！");
		return;
	}
	consoleMes($("#manageContent"),2000,"success","正在跳转手机更绑！");//success、info、warning、danger
	setTimeout(function () {
    	$(".verification-item").eq(1).hide();
    	$(".safe-item").eq(1).show();
    }, 2500);
	$.ajax({
        type: "GET",
        url:  gobalWebUrl+"member/login",
        async: true,//false使用同步的方式,true为异步方式
        contentType: "application/json; charset=utf-8",
        data:{"count":memberMobile},
        dataType: "json",
        success:function(backData){
            if(backData.result==202){
            	consoleMes($("#webContent"),2000,"success",backData.message);//success、info、warning、danger
            }else{
            	consoleMes($("#webContent"),2000,"warning",backData.message);//success、info、warning、danger
            	
            }
        },
        error:function(backData){

        }

    });
}*/
/*获取验证码-手机绑定*/
/*function newGetVerificationCodeMB(){
	var newMemberMobileMB=$("#newMemberMobileMB").val().trim();
	if(newMemberMobileMB==null || newMemberMobileMB==""){
		consoleMes($("#manageContent"),2000,"warning","请输入手机！");
		return;
	}
	if(!ischeckmobile(newMemberMobileMB)){
		consoleMes($("#manageContent"),2000,"warning","手机格式不正确！");
		return;
	}
	consoleMes($("#manageContent"),2000,"success","验证码已经发送至手机！");//success、info、warning、danger
	$.ajax({
        type: "GET",
        url:  gobalWebUrl+"member/login",
        async: true,//false使用同步的方式,true为异步方式
        contentType: "application/json; charset=utf-8",
        data:{"count":memberMobile},
        dataType: "json",
        success:function(backData){
            if(backData.result==202){
            	consoleMes($("#manageContent"),2000,"success",backData.message);//success、info、warning、danger
            }else{
            	consoleMes($("#manageContent"),2000,"warning",backData.message);//success、info、warning、danger
            	
            }
        },
        error:function(backData){

        }

    });
}*/
/*提交手机和验证码-手机绑定*/
/*function newSubmitMesMB(){
	var newMemberMobileMB=$("#newMemberMobileMB").val().trim();
	var newVerificationCodeMB=$("#newVerificationCodeMB").val().trim();
	if(newMemberMobileMB==null || newMemberMobileMB==""){
		consoleMes($("#manageContent"),2000,"warning","请输入手机！");
		return;
	}
	if(!ischeckmobile(newMemberMobileMB)){
		consoleMes($("#manageContent"),2000,"warning","手机格式不正确！");
		return;
	}
	if(newVerificationCodeMB==null || newVerificationCodeMB==""){
		consoleMes($("#manageContent"),2000,"warning","请输入验证码！");
		return;
	}
	if(newVerificationCodeMB!="666"){
		consoleMes($("#manageContent"),2000,"warning","验证码不正确！");
		return;
	}
	consoleMes($("#manageContent"),2000,"success","手机更绑成功，正在跳转登录页面！");//success、info、warning、danger
	setTimeout(function () {
    	window.location.href=gobalWeb+"login.html";
    }, 2500);
	$.ajax({
        type: "GET",
        url:  gobalWebUrl+"member/login",
        async: true,//false使用同步的方式,true为异步方式
        contentType: "application/json; charset=utf-8",
        data:{"count":memberMobile},
        dataType: "json",
        success:function(backData){
            if(backData.result==202){
            	consoleMes($("#manageContent"),2000,"success",backData.message);//success、info、warning、danger
            }else{
            	consoleMes($("#manageContent"),2000,"warning",backData.message);//success、info、warning、danger
            	
            }
        },
        error:function(backData){

        }

    });
};*/